package top.scsoul.voes.web.controller.system;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import top.scsoul.voes.common.core.domain.AjaxResult;
import top.scsoul.voes.common.core.domain.entity.Dictionary;
import top.scsoul.voes.examination.entity.Subject;
import top.scsoul.voes.examination.service.SubjectService;
import top.scsoul.voes.system.service.DictionaryService;

import javax.validation.constraints.NotEmpty;
import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/api/dict")
public class DictionaryController {
    @Autowired
    DictionaryService dictionaryService;
    @Autowired
    SubjectService subjectService;
    @RequestMapping("/queryByTypeCode")
    public AjaxResult queryByTypeCode(@NotEmpty String typeCode) {
        Dictionary dictionary = new Dictionary();
        dictionary.setTypeCode(typeCode);
        List<Dictionary> dictionaries = dictionaryService.queryAll(dictionary);
        return AjaxResult.success(dictionaries);
    }

    /**
     * 科目字典
     *
     * @return
     */
    @RequestMapping("/subjectDict")
    public AjaxResult subjectDict() {
        List<Subject> subjects = subjectService.queryAll();
        return AjaxResult.success(subjects);
    }
}
